package com.example.Web;

import com.example.Web.pojo.A;
import com.example.Web.pojo.School;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

@Controller
public class Test {
    /**
     * 自定义属性
     */
    @Value("${mykey}")
    public String string;

    @ResponseBody
    @RequestMapping("/test")
    public String test(){
        return string;
    }

    /**
     * 自定义对象
     */
    @Resource
    private School school;

    @ResponseBody
    @RequestMapping("/test02")
    public School test02(){
        return school;
    }

    /**
     * 自定义对象
     */
//  取出对象数据
    @Autowired
    private A a;

//    JSON格式显示出来
    @ResponseBody
    @RequestMapping("/test03")
    public A test03(){
        return a;
    }
}
